package main

import (
	"fmt"
	"os"
	"os/signal"

	"api/examples/server/server"
	"api/examples/server/service"
)

func main() {
	userService := service.NewUserService()
	httpServer := server.NewHTTPServer(userService)
	grpcServer := server.NewGRPCServer(userService)

	go func() {
		if err := httpServer.Start(); err != nil {
			panic(err)
		}
	}()

	go func() {
		if err := grpcServer.Start(); err != nil {
			panic(err)
		}
	}()

	// Wait for interrupt signal to gracefully shutdown the server with
	// a timeout of 5 seconds.
	quit := make(chan os.Signal, 1)
	signal.Notify(quit, os.Interrupt)
	<-quit
	fmt.Printf("Server exiting ...")
}
